<?php



include('db.inc.php');

function getCatePath($cid,&$result=array()){
	$sql = "select * from deepcate where id =$cid";
	$rs = mysql_query($sql);
	$row = mysql_fetch_assoc($rs);
	if($row){
		$result[] = $row;
		getCatePath($row['pid'],$result);
	}
	krsort($result);
	return $result;
}

// $rs = getCatePath(9);
// print_r($rs);
function displayCatePath($cid,$url="cate.php?cid="){
$rs = getCatePath($cid);

$str = '';
foreach ($rs as $key => $value) {
	$str .= "<a href='{$url}{$value['id']}'>{$value['catename']}</a>".'>';
}
return $str;
}
echo displayCatePath(9);